var url = location.search; //获取url中"?"符后的字串 ('?modFlag=business&role=1')
 var theRequest = new Object();
 var flag ='';
 if (url.indexOf('?') != -1) {
	 var str = url.substr(1); //substr()方法返回从参数值开始到结束的字符串；
	 var strs = str.split('&');
		 for (var i = 0; i < strs.length; i++) {
		    theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1]
		 }
		 flag=theRequest.flag; //此时的theRequest就是我们需要的参数；
		 console.log(flag)
 }
 var height = document.body.clientHeight
 $(".box").css("height",height-90);
var type=0;
var fn=0;
$(function(){
	$(".shou").css("color","#F9C486");
	getDetailed(0);
})
$(".zhi").click(function(){
	$(this).css("color","#F9C486");
	$(".shou").css("color","#FFFFFF");
	type=1;
	fn=0;
	getDetailed(1);
})
$(".shou").click(function(){
	$(this).css("color","#F9C486");
	$(".zhi").css("color","#FFFFFF");
	type=0;
	fn=0;
	getDetailed(0);
})

function getDetailed(type){
	$.ajax({
		url:'../detailedController/getDetailed',
		data:{
			"type":type,
			"flag":flag,
			"fn":0
		},
		success:function(data){
			console.log(data)
			if(type==0){
				var i="+";
			}else{
				var i="-";
			}
			if(data==null || data=="" ||data.length==0){
				 $(".box").html("<div><img src='../image/none.jpg' style='width: 300px;height:300px;margin-left: 225px;margin-top:100px;'></div>");
			}else{
				$(".box").html("");
				fn=fn+30
				$.each(data,function(idex,item){
					var operationTime=new Date(item.operationTime).format("yyyy-MM-dd hh:mm:ss")
					$(".box").append("<div class='back'><div class='play'><div class='played'>"+item.title+"</div><div class='time'>"+operationTime+"</div></div><div class='price'><label>"+i+"</label><label>"+item.money+"</label></div></div>")
				})
			}
		}
	})
}
const scrollDom = document.getElementById('box');

scrollDom.onscroll = () => {
	if (scrollDom.clientHeight + parseInt(scrollDom.scrollTop) === scrollDom.scrollHeight) {
		$.ajax({
			url:'../detailedController/getDetailed',
			data:{
				"type":type,
				"flag":flag,
				"fn":fn
			},
			success:function(data){
				console.log(data)
				if(flag==0){
					var i="+";
				}else{
					var i="-";
				}
				fn=fn+30
				$.each(data,function(idex,item){
					var operationTime=new Date(item.operationTime).format("yyyy-MM-dd hh:mm:ss")
					$(".box").append("<div class='back'><div class='play'><div class='played'>"+item.title+"</div><div class='time'>"+operationTime+"</div></div><div class='price'><label>"+i+"</label><label>"+item.money+"</label></div></div>")
				})
			}
		})
	  }
}
	  
